package 第1周_线性查找法.使用自定义类测试我们的算法;

public class Student {

    private String name;

    public Student(String name){
        this.name = name;
    }

    /**
     * 重写equals()
     * @return
     */
    @Override
    public boolean equals(Object student){
        //判断传过来的student和调用的student是同一个地址
        if (this == student){
            return true;
        }
        //判断传过来的student是否为空
        if (student == null){
            return false;
        }
        //判断强转的类型是否是本类里面的
        if (student.getClass() != this.getClass()){
            return false;
        }

        Student otherStudent = (Student)student;
        return this.name.equals(otherStudent.name);
    }
}
